package com.xinan.weixin.msg;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

@TableBind(tableName = "wx_msgtype")
public class Msgtype extends Model<Msgtype>{
    public static final Msgtype dao = new Msgtype();

    //columns START
    private String ID = "id";  //
    private String MSGTYPE = "msgtype";  //类型
    private String TEXTNAME = "textname";  //
    private String YXBZ = "yxbz";  //有效标志
    private String PID="pid";//上级节点
    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
    public void setMsgtype(String value) {
        set(MSGTYPE, value);
    }

	public String getMsgtype() {
		return get(MSGTYPE);
	}
    public void setTextname(String value) {
        set(TEXTNAME, value);
    }

	public String getTextname() {
		return get(TEXTNAME);
	}
    public void setYxbz(String value) {
        set(YXBZ, value);
    }

	public String getYxbz() {
		return get(YXBZ);
	}
	//columns END

    public List<Msgtype> findAll() {
        return find("select * from wx_msgtype");
    }

    public List<Record> findAlls(String where) {
        String sql="  from wx_msgtype ";
        if(StringKit.notBlank(where)){
            sql += " where " + where;
        }
        return  Db.find( "select * " + sql) ;
    }

    public Page<Msgtype> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from wx_msgtype";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
}

